/*
 *  Copyright 2008-2010 www.jrails.org
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.rails.extjs.chart;

import java.util.ArrayList;
import java.util.List;

import org.rails.extjs.Option;
import org.rails.extjs.data.Store;

public abstract class Chart extends FlashComponent {
	
	public static final String CHART_URL = "http://yui.yahooapis.com/2.8.0/build/charts/assets/charts.swf";

	private List<Series> series = new ArrayList<Series>();
	
	public Chart() {
		super();
	}

	public Chart(Option configOptions) {
		super(configOptions);
	}

	public Chart(String id) {
		super(id);
	}
	
	@Override
	public void createItems(){
		super.createItems();
		if(series.size() > 0)
			addOption("series",series);
	}
	
	public void setSeries(List<Series> series){
		this.series = series;
	}
	
	public List<Series> getSeries(){
		return series;
	}
	
	public void addSeries(Series ser){
		series.add(ser);
	}
	
	public void insertSeries(int index,Series ser){
		series.add(index, ser);
	}
	
	public void removeSeries(int index){
		series.remove(index);
	}
	
	public void clearSeries(){
		series.clear();
	}
	
	public Series getSeries(int index){
		return series.get(index);
	}
	
	public void setChartStyle(Style chartStyle) {
		addOption("chartStyle", chartStyle);
	}

	public Style getChartStyle() {
		return (Style) getOption("chartStyle");
	}

	public void setDisableCaching(Boolean disableCaching) {
		addOption("disableCaching", disableCaching);
	}

	public Boolean isDisableCaching() {
		return getBoolean("disableCaching", true);
	}

	public void setExtraStyle(Style extraStyle) {
		addOption("extraStyle", extraStyle);
	}

	public Style getExtraStyle() {
		return (Style) getOption("extraStyle");
	}

	public void setSeriesStyles(Style seriesStyles) {
		addOption("seriesStyles", seriesStyles);
	}

	public Style getSeriesStyles() {
		return (Style) getOption("seriesStyles");
	}
	
	public void setUrl(String url){
		addOption("url",url);
	}
	
	public String getUrl(){
		return getString("url","");
	}

	public void setStore(Store store) {
		addOption("store",store);
	}

	public Store getStore() {
		return (Store)getOption("store");
	}

}
